<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>停车场会员--${headerTitle }</title>
	
  	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1";/><!-- IE的渲染模式 -->
    <meta name="renderer" content="webkit"><!-- 浏览器高速模式 -->
    
    <meta name="keywords" content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="description" content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="author" content="blackshadowwalker" />
    
	<link href="css/common.css" rel="stylesheet"/>
	<link href="bootstrap/3/css/bootstrap.css" rel="stylesheet"/>

	<script src="scripts/jquery/jquery-1.7.min.js"></script>
	<script src="bootstrap/3/js/bootstrap.min.js"></script>
	<link href="bootstrap/3/css/datepicker.css" rel="stylesheet"/>
	<script src="bootstrap/3/js/bootstrap-datepicker.js"></script>
	
	<script src="scripts/validateForm.js?t=991212"></script>
	<script src="index/js/index.js" type="text/javascript"></script>
	
	<script type="text/javascript">
		var msg = "${msg}";
		if(msg!="")
			alert(msg);
			
	</script>
	
	
	<style>
		body{
			margin-left: 10px;
			margin-top: 7px;
			width:95%;
		}
	</style>
	<script type="text/javascript">
		function test(name) {
				var url = "ParkManagerAction?method=checkRealkName";
				var inp = document.getElementById("Rname");
				$.ajax({
					type : "POST",
					url : url,
					data : "parkManager.userName=" + name,
					success : function(ret) {
						if (ret.error != 0) {
							alert( ret.msg );
							inp.focus();
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						if (window.console) {
							console.log(XMLHttpRequest);
							console.log(textStatus);
							console.log(errorThrown);
						}
						alert(errorThrown);
					}
				});
			}
	</script>
	
</head>

<body>
<div  >
	
	<div>
		<div class="alert-info" style="">
			<a href="${action}" class="btn btn-warning">返回</a>
			<div style="display:inline;margin-left:30px;color:#f00;">
				${msg }
			</div>
		</div >
	</div>
	
	<form id="myform" name="myform" class="form-horizontal" role="form"  action="${action }?id=${id}&method=${method}" method="post" >

			<s:if test="flag==1">
				<s:set name="notEmpty" value="'false'" />
			</s:if>
			<s:else>
				<s:set name="notEmpty" value="'true'" />
			</s:else>

			<div class="form-group">
				<label class="col-sm-2 control-label"> 头像:</label>
				<div class="col-sm-5" id="userphoto" >
					<input type="hidden" name="parkManager.photo"
						value="${parkManager.photo}" style="width:200px;" />
				    <img
						src="${parkManager.photo}" for="parkManager.photo" alt="头像"
						style="width:120px;height:130px;cursor:pointer;"
						onClick="chooserPhoto();" /> 
					<input id="uploadphoto" type="button" class="btn " onClick="chooserPhoto();" alt="选择头像" value="..." />
					
				</div>
			</div>
			
			<div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span> 用户帐号：</label>
		    <div class="col-sm-5">
		    	<s:if test="flag==1">
		    		<input type="text" class="form-control" value="${parkManager.userName}" placeholder="用户帐号"  
		      		 disabled/>
		    	</s:if>
		      	<s:else>
		      		<input type="text" class="form-control" name="parkManager.userName"  value="${parkManager.userName}" id="Rname" placeholder="用户帐号" 
		      		 isValidate="true" msg="用户帐号" notEmpty="true"  notSpecial="true"  specialChar="~!@#$%^&*()+ |?"  leng="20" minLeng="6" onblur="test(this.value),Form.validate(this,'checkUserName')"/>
		      	</s:else>
		      	 <span class="errorMessage" >
					<s:property value="errors['parkManager.userName'][0]" />
				</span>
		      	(支持字母、数字、下划线的组合，长度6-20)
		    </div>
		  </div>
	     <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>真实姓名：</label>
		    <div class="col-sm-5">
		      	<input type="text" class="form-control" name="parkManager.realName"  value="${parkManager.realName}" placeholder="真实姓名" 
		      	onblur="Form.validate(this,'checkRealName')"  msg="真实姓名"
		      	isValidate="true" notEmpty="true"  notSpecial="true"  specialChar="~!@#$%^&*()+,.\ |?" leng="20" minLeng="4"  />
		      	 <span class="errorMessage" >
					<s:property value="errors['parkManager.realName'][0]" /> 
				</span>
		      	(支持汉字、字母组合，长度2-20)
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>个人简介：</label>
		    <div class="col-sm-5">
		      	<textarea type="text" class="form-control" name="parkManager.introduction" placeholder="个人简介" 
		      	isValidate="true" notEmpty="false"  notSpecial="true"  specialChar="~!@#$%^&*()+ |?" leng="1000" minLeng="10">${parkManager.introduction}</textarea>
		      	 <span class="errorMessage" >
					<s:property value="errors['parkManager.introduction'][0]" /> 
				</span>
		      	(支持汉字、字母、数字、下划线，长度4-20)
		    </div>
		  </div>
		  
    	
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>密码</label>
		    <div class="col-sm-5">
				<input type="password" class="form-control" name="parkManager.userPasswd" placeholder="密码"  value="" 
				onblur="Form.validate(this,'checkPassword')" 
				isValidate="true" notEmpty="<s:property value="notEmpty" />"  notSpecial="true"  specialChar="~!@#$%^&*()+ |?" msg="密码"  leng="20" minLeng="6"/>
				 <span class="errorMessage" >
					<s:property value="errors['parkManager.userPasswd'][0]" />
				</span>
				(支持字母、数字、下划线，长度6-20) 	
		    </div>
		  </div>
		  
		   <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>再次输入密码：</label>
		    <div class="col-sm-5">
		      	<input type="password" class="form-control" confirmSameValue="parkManager.userPasswd"   placeholder="再次输入密码" value=""
		      	onblur="Form.validate(this,'checkPassword')"  msg="密码" 
		      	isValidate="true" notEmpty="<s:property value="notEmpty" />"  notSpecial="true"  specialChar="~!@#$%^&*()+ |?"  leng="20" minLeng="6" />
		      	 <span class="errorMessage" >
					<s:property value="errors['parkManager.userPasswd'][0]" />
				</span>
				(支持字母、数字、下划线，长度6-20)
		    </div>
		  </div>
		  
		    <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>身份证号：</label>
		    <div class="col-sm-5">
		      	<input type="text" class="form-control" name="parkManager.idCard"  value="${parkManager.idCard}" placeholder="身份证号" 
		      	isValidate="true" notEmpty="false"  notSpecial="true" isIDCard="true"/>
		      	<span class="errorMessage" >
					<s:property value="errors['parkManager.idCard'][0]" />
				</span>
		    </div>
		  </div>
		  
		   <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>银行账号：</label>
		    <div class="col-sm-5">
 		      	<input type="text" class="form-control" name="parkManager.bankAccount"  value="${parkManager.bankAccount}" placeholder="银行账号" 
		      	isValidate="true" notEmpty="false"  notSpecial="true" isNum="true"/>
		      	<span class="errorMessage" >
					<s:property value="errors['parkManager.bankAccount'][0]" />
				</span>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label"><span style="color:#f00">*</span>手机号：</label>
		    <div class="col-sm-5">
				<input type="text" class="form-control" name="parkManager.phone" value="${parkManager.phone }"  placeholder="手机号" notEmpty="true"
					isValidate="true" isMobile="true" isn/> 	
		    </div>
		  </div>
		  
  		  <div class="form-group">
		    <label   class="col-sm-2 control-label"><span style="color:#f00">*</span>用户状态：</label>
		    <div class="col-sm-5">
				<select  class=form-control  name="parkManager.status" >
					<option value="1" selected>正常</option>
					<option value="0">锁定</option>
				</select>
				<script>
		    		 $("select[name='parkManager.status']").val("${parkManager.status}");
		    	</script>
		    </div>
		  </div>
		 
		  <div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label"> </label>
		    <div class="col-sm-5">
	    			<input class="btn btn-success btn-lg btn-block"  type=submit value="${headerTitle}"   />
					<input class="btn btn-primary btn-lg btn-block"  type="reset" value="重置"  />
		     </div>
		  </div>
		  
	</form>
	<div style="display:none;" id="uploaddiv">
		<form action="UploadAction?callback=callback"  method="post" ENCTYPE="multipart/form-data" target="hidden_frame" >
			<input type=file name=file onchange="uploadPhoto(this);" />
			<input type="text" name="dir"  value="user/photos" /><br>
		</form>
		<iframe name="hidden_frame"></iframe>
	</div>
</div>
</body>
<script type="text/javascript">
		$(document).ready(
				function() {
					$("#myform input[type='submit']").click(
						function(e) {
							e.preventDefault();//阻止提交按钮的默认 action
							//	  alert("Submit prevented");
							if (!$("#myform").validateForm()) {
								return;
							}
							
							var btn = $(this);
							btn.val("正在提交...");
							btn.addClass("disabled");
							$(btn).parent().children("input[type='reset']")
									.addClass("disabled");
							$("#myform").submit();
						});
				});
		function uploadPhoto(obj) {
			if($.trim( $(obj).val())!=""){
				$("#uploadphoto").val("正在上传....");
				$("#uploadphoto").addClass("disabled");
				$(obj).parent().submit();
			} 			
		}

		function callback(json) {
			if (window.console)
				console.log(json);
			$("#uploadphoto").removeClass("disabled");
			$("#uploadphoto").val("...");
			if (json.error == 0 || json.error==-2) {
				if (json.data.length >= 1) {
					if(json.data[0].error==0){
						$("input[name='parkManager.photo']").val(json.data[0].path);
						$("img[for='parkManager.photo']").attr("src",json.data[0].path);
					}else{
						alert(json.data[0].msg);
					}
				} else {
					alert("上传失败");
				}
			} else {
				alert(json.msg);
			}
		}

		function chooserPhoto() {
			$("#uploaddiv input[name=file]").click();
		}
	</script>
</html>